The restricted shell is a Unix shell that restricts some of the capabilities available to an interactive user session, or to a shell script, running within it. It is intended to provide an additional layer of security, but is insufficient to allow execution of entirely untrusted software. A restricted mode operation is found in the original Bourne shell[1] and its later counterpart bash,[2] and in the Korn shell.[3] In some cases a restricted shell is used in conjunction with a chroot jail, in a further attempt to limit access to the system as a whole.
Contents |
The restricted mode of the Bourne shell sh, and its POSIX workalikes, is used when the interpreter is invoked in one of the following ways:
The restricted mode of bash is used when bash is invoked in one of the following ways:
Similarly the Korn shell's restricted mode is produced by invoking it thus:
The following operations are not permitted in a restricted shell:
bash adds further restrictions, including:[2]
Restrictions in the restricted Korn shell are much the same as those in the restricted Bourne shell.[4]
The restricted shell is not completely secure. A user can break out of the restricted environment by running a program that features a shell function. The following is an example of the shell function in vi being used to escape from the restricted shell:
vi :set shell=/bin/sh :shell